/*
 * Licensed this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 * AUTHOR: Sebastian Ritter
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace org.boapi.shop {
  /// <summary>
  /// International Standard Music Number [ISMN] since 01.01.2008 
  /// with 13 digits. Before 01.01.2008 ISMN have M prefix. 
  /// </summary>
  /// <version>2.0.0.0</version>
  public class ISMN : org.boapi.core.IChecknumber {

    /// <summary>
    /// Delegate object
    /// </summary>
    private GTIN delegateObject;

    /// <summary>
    /// Construct
    /// </summary>
    public ISMN () {
      this.delegateObject = new GTIN ();
    }
    /// <summary>
    /// Set the ISMN
    /// </summary>
    /// <param name="ismn"></param>
    public override void setCompleteValue (params string[] ismn) {
      this.delegateObject.setCompleteValue (ismn[0]);
      if (!(this.delegateObject.getNumber().StartsWith ("9790"))) {
        throw new ArgumentException ("Number is not an ISMN, because it starts not with 979-0", "ismn");
      }
    }

    /// <summary>
    /// Is the checknumber correct
    /// </summary>
    /// <returns></returns>
    public override sealed bool isChecknumberCorrect () {
      return this.delegateObject.isChecknumberCorrect ();
    }
    /// <summary>
    /// Set the checknumber
    /// </summary>
    /// <param name="digit"></param>
    protected override void setChecknumber (char digit) {
      this.delegateObject.setChecknumber (digit);
    }
    /// <summary>
    /// Return the checknumber
    /// </summary>
    /// <returns></returns>
    protected override char getChecknumber () {
      return this.delegateObject.getChecknumber ();
    }
    /// <summary>
    /// The number of ISMN
    /// </summary>
    /// <returns></returns>
    public override String getNumber () {
      return this.delegateObject.getNumber();
    }

  }
}
